package org.Vancl.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.Vancl.Dao.menuDao;
import org.Vancl.Dao.ImpI.menuDaoImpI;
import org.Vancl.entity.menu;

@WebServlet(urlPatterns="/erjimenu.shtml")
public class erjimenu extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("text/html; charset=utf-8");
		String type=req.getParameter("yiji");
		
		menuDao md=new menuDaoImpI();
		List<menu> listmenu=md.getid(Integer.parseInt(type));
		
		req.setAttribute("listmenu", listmenu);
		
		PrintWriter out=resp.getWriter();
		StringBuffer sb=new StringBuffer();
		for (menu menu : listmenu) {
			sb.append(menu.getM_name());
			sb.append(".");
			sb.append(menu.getM_id());
			sb.append(",");
		}
		
		
		String menustr=sb.toString();
		out.print(menustr);
		
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
